home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / circuit.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2005-06-30  |  4.5 KB  |  147 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; Circuit board effect
  4. ; Copyright (c) 1997 Adrian Likins
  5. ; aklikins@eos.ncsu.ed
  6. ;
  7. ;  Genrates what looks a little like the back of an old circuit board.
  8. ;  Looks even better when gradmapped with a suitable gradient.
  9. ;
  10. ; This script doesnt handle or color combos well. ie, black/black 
  11. ;  doesnt work..
  12. ;  The effect seems to work best on odd shaped selections because of some
  13. ; limitations in the maze codes selection handling ablity
  14. ;
  15. ;
  16. ; This program is free software; you can redistribute it and/or modify
  17. ; it under the terms of the GNU General Public License as published by
  18. ; the Free Software Foundation; either version 2 of the License, or
  19. ; (at your option) any later version.
  20. ; This program is distributed in the hope that it will be useful,
  21. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23. ; GNU General Public License for more details.
  24. ; You should have received a copy of the GNU General Public License
  25. ; along with this program; if not, write to the Free Software
  26. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27.  
  28.  
  29. (define (script-fu-circuit image
  30.                drawable
  31.                mask-size
  32.                seed
  33.                remove-bg
  34.                keep-selection
  35.                separate-layer)
  36.   (let* (
  37.      (type (car (gimp-drawable-type-with-alpha drawable)))
  38.      (image-width (car (gimp-image-width image)))
  39.      (image-height (car (gimp-image-height image)))
  40.     )
  41.     
  42.     (gimp-context-push)
  43.  
  44.     (gimp-image-undo-group-start image)
  45.  
  46.     (gimp-layer-add-alpha drawable)
  47.     
  48.     (if (= (car (gimp-selection-is-empty image)) TRUE)
  49.     (begin
  50.       (gimp-selection-layer-alpha drawable)
  51.       (set! active-selection (car (gimp-selection-save image)))
  52.       (set! from-selection FALSE))
  53.     (begin
  54.       (set! from-selection TRUE)
  55.       (set! active-selection (car (gimp-selection-save image)))))
  56.     
  57.     (set! selection-bounds (gimp-selection-bounds image))
  58.     (set! select-offset-x (cadr selection-bounds))
  59.     (set! select-offset-y (caddr selection-bounds))
  60.     (set! select-width (- (cadr (cddr selection-bounds)) select-offset-x))
  61.     (set! select-height (- (caddr (cddr selection-bounds)) select-offset-y))
  62.     
  63.     (if (= separate-layer TRUE)
  64.     (begin
  65.       (set! effect-layer (car (gimp-layer-new image
  66.                           select-width
  67.                           select-height
  68.                           type
  69.                           "effect layer"
  70.                           100
  71.                           NORMAL-MODE)))
  72.       
  73.       (gimp-image-add-layer image effect-layer -1)
  74.       (gimp-layer-set-offsets effect-layer select-offset-x select-offset-y)
  75.       (gimp-selection-none image)
  76.       (gimp-edit-clear effect-layer)
  77.       (gimp-selection-load active-selection)
  78.       (gimp-edit-copy drawable)
  79.       
  80.       (let ((floating-sel (car (gimp-edit-paste effect-layer FALSE))))
  81.         (gimp-floating-sel-anchor floating-sel)
  82.         )
  83.       (gimp-image-set-active-layer image effect-layer ))
  84.       (set! effect-layer drawable)
  85.     )
  86.     (set! active-layer effect-layer)
  87.  
  88.     (if (= remove-bg TRUE)
  89.     (gimp-context-set-foreground '(0 0 0))
  90.     (gimp-context-set-foreground '(14 14 14)))
  91.  
  92.     (gimp-selection-load active-selection)
  93.     (plug-in-maze 1 image active-layer 5 5 TRUE 0 seed 57 1)
  94.     (plug-in-oilify 1 image active-layer mask-size 0)
  95.     (plug-in-edge 1 image active-layer 2 1 0)
  96.     (if (= type RGBA-IMAGE)
  97.       (gimp-desaturate active-layer))
  98.     
  99.     (if (and
  100.      (= remove-bg TRUE)
  101.      (= separate-layer TRUE))
  102.     (begin
  103.       (gimp-by-color-select
  104.        active-layer
  105.        '(0 0 0)
  106.        15
  107.        2
  108.        TRUE
  109.        FALSE
  110.        10
  111.        FALSE)
  112.       (gimp-edit-clear active-layer)))
  113.     
  114.     (if (= keep-selection FALSE)
  115.     (gimp-selection-none image))
  116.     
  117.     (gimp-image-remove-channel image active-selection)
  118.     (gimp-image-set-active-layer image drawable)
  119.  
  120.     (gimp-image-undo-group-end image)
  121.  
  122.     (gimp-displays-flush)
  123.  
  124.     (gimp-context-pop)))
  125.  
  126. (script-fu-register "script-fu-circuit"
  127.             _"_Circuit..."
  128.             "Fills the current selection with something that looks 
  129.                      vaguely like a circuit board."
  130.             "Adrian Likins <adrian@gimp.org>"
  131.             "Adrian Likins"
  132.             "10/17/97"
  133.             "RGB* GRAY*"
  134.             SF-IMAGE       "Image"            0
  135.             SF-DRAWABLE    "Drawable"         0
  136.             SF-ADJUSTMENT _"Oilify mask size" '(17 3 50 1 10 0 1)
  137.             SF-ADJUSTMENT _"Circuit seed"     '(3 1 3000000 1 10 0 1)
  138.             SF-TOGGLE     _"No background (only for separate layer)" FALSE
  139.             SF-TOGGLE     _"Keep selection"   TRUE
  140.             SF-TOGGLE     _"Separate layer"   TRUE)
  141.  
  142. (script-fu-menu-register "script-fu-circuit"
  143.              _"<Image>/Script-Fu/Render")
  144.